int I1 = 4; //input1 to control direction of turning
int I2 = 7;//input2 to control direction of turning
int pwm = 5;//pwm in pin5
int rSW = 12;//right switch
int lSW = 13;//left switch
int valr = 0;//value for recieving right switch
int vall = 0; //value for receivinf left swich

void setup(){
  Serial.begin(9600);
  //declaration of input and output
  pinMode(rSW,INPUT);
  pinMode(lSW,INPUT);
  pinMode(I1, OUTPUT);
  pinMode(I2, OUTPUT);
}

void loop(){
  //receive valuse in each switch
  valr = digitalRead(rSW);
  vall = digitalRead(lSW);
  //check condition of each switch(we use on-off-on switch)
 if(valr == HIGH){
   //counterclockwise
     Serial.println("COUNTERCLOCKWISE");
     analogWrite(pwm,7);
    digitalWrite(I1,LOW);
    digitalWrite(I2,HIGH);
  }
  else if(vall == HIGH){
    //clockwise
    Serial.println("CLOCKWISE");
    analogWrite(pwm,7);
    digitalWrite(I1,HIGH);
    digitalWrite(I2,LOW);
  }
  //Turn off
  else{
    //pwn equal to zero(speed is zero)
    analogWrite(pwm,0);
   Serial.println("Stop working");
  }

}
